﻿using CompanyManageIRepository;
using CompanyManageModel;
using CompanyManageRepositoryIServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompanyManageRepositoryServices
{
    public class EmployeeServices : BaseServices<Employee>, IEmployeeServices
    {
        IEmployeeRepository _dal;
        public EmployeeServices(IEmployeeRepository dal)
        {
            this._dal = dal;
            base.baseDal = dal;
        }
        public async Task<List<Result>> GetTitleCount()
        {
            var EmployeeList = await baseDal.Query();
            var group = EmployeeList.GroupBy(p => p.TITLE).ToList();
            var resultList = new List<Result>();
 
            for(int i=0;i< group.Count(); i++)
            {
                var result = new Result();
                result.Title = group[i].Key;
                result.Count = group[i].Count();
                resultList.Add(result);

            }
            return resultList;


        }
        
    }

   
}
